package test;

import jtarget.view.board.SmallTargetBoardView;
import javax.swing.*;
import java.awt.*;

public class GroupViewRenderer extends DefaultListCellRenderer {
    GroupListModel model;
    static Color selectedColor = new Color(180, 200, 250);
    static Color unselectedColor = Color.WHITE;

    void setBoardListModel(GroupListModel model) {
        this.model = model;
    }

    public Component getListCellRendererComponent(JList list,
                                                  Object value,
                                                  int index,
                                                  boolean isSelected,
                                                  boolean hasFocus) {
        Color background;
        super.getListCellRendererComponent(list,
                value,
                index,
                isSelected,
                hasFocus);
        SmallTargetBoardView component = (SmallTargetBoardView) model.getElementAt(index);
        background = isSelected?selectedColor:unselectedColor;
        component.setBackground(background);
        return component;
    }
}
